//
//  COPayWayCell.m
//  MJApp
//
//  Created by John on 15/3/30.
//  Copyright (c) 2015年 wangliang. All rights reserved.
//

#import "COPayWayCell.h"

@interface COPayWayCell ()

@property (weak, nonatomic) IBOutlet UIImageView *picImageView;
@property (weak, nonatomic) IBOutlet UILabel *payNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *descLabel;

@end

@implementation COPayWayCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+(instancetype)cellForTableview:(UITableView *)tableview{

    static NSString * ID = @"COPayWayCell";
    COPayWayCell * cell = [tableview dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[NSBundle mainBundle] loadNibNamed:ID owner:nil options:nil].lastObject;
    }
    cell.cellH = 52;
    return cell;
}


- (void)setInfoDic:(NSDictionary *)infoDic {
    
    [super setInfoDic:infoDic];
    self.payNameLabel.text = infoDic[@"name"];
    self.picImageView.image = [UIImage imageNamed:infoDic[@"pic"]];
    self.descLabel.text = infoDic[@"desc"];
    self.selectBtn.selected = [infoDic[@"isSelect"] boolValue];
}

- (IBAction)select:(id)sender {
    
    NSRange range =[self.infoDic[@"name"] rangeOfString:@"支付宝"];
    BOOL isPay = range.length > 0;
    UIButton *btn = (UIButton *)sender;
    btn.selected = !btn.selected;
    if ([self.delegate respondsToSelector:@selector(cellProtocolWithObj:withDic:)]) {
        
        [self.delegate cellProtocolWithObj:self withDic:@{@"isWeixin":@(!isPay)}];
    }
}
@end
